package com.ckchina.admin.ckadmin.controller.dto;

import java.io.Serializable;

import org.apache.commons.lang3.builder.ReflectionToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;

import com.zhuzi.exception.ErrorCode;

/**
 * 客户端返回数据的DTO对象
 */
public class ResponseData implements Serializable {

	private static final long serialVersionUID = 1L;

	/** 执行状态返回码 {@link ErrorCode} */
	private int code = ErrorCode.OK.value;

	/** 请求的uuid原封返回 */
	private String uuid;

	/** 返回的具体数据 */
	private Object value;

	private Boolean success = true;

	public ResponseData() {
		super();
	}

	public ResponseData(int code, String uuid) {
		super();
		this.code = code;
		this.uuid = uuid;
		if(code!=ErrorCode.OK.value){
			this.value=ErrorCode.getMemoByValue(code);
		}
	}

	public ResponseData(int code, String uuid, Object value) {
		super();
		this.code = code;
		this.uuid = uuid;
		if(code!=ErrorCode.OK.value){
			this.value=ErrorCode.getMemoByValue(code);
		}else{
			this.value = value;
		}
	}

	public ResponseData(int code, String uuid, Object value, Boolean success) {
		super();
		this.code = code;
		this.uuid = uuid;
		this.value = value;
		this.success = success;
	}

	public int getCode() {
		return code;
	}

	public void setCode(int code) {
		this.code = code;
	}

	public String getUuid() {
		return uuid;
	}

	public void setUuid(String uuid) {
		this.uuid = uuid;
	}

	public Object getValue() {
		return value;
	}

	public void setValue(Object value) {
		this.value = value;
	}

	public Boolean getSuccess() {
		return success;
	}

	public void setSuccess(Boolean success) {
		this.success = success;
	}

	public String toString() {
		return ReflectionToStringBuilder.toString(this, ToStringStyle.SHORT_PREFIX_STYLE);
	}

}
